import App from './App';
import React from 'react';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import store from './store';
import 'antd/dist/antd.less';
import '@/assets/css/main.less';
import '@/assets/css/mediaScreen.css';
import '@/assets/font/iconfont.css';
import zhCN from 'antd/es/locale/zh_CN';
import { ConfigProvider } from 'antd';
import { AppProviders } from './views/Context';
// import i18n (needs to be bundled ;))
import './utils/i18next/i18n';

import AgentService from '@/modules/Agent';

AgentService.createView('agent-widget-root', false);

const { configure } = AgentService;
configure.setServiceUrl(loginUrl);
configure.setAwsFileUrl(awsFileUrl);
configure.setCustomerUrl(customerUrl);
configure.setPublicKey(publicKey);
configure.setFormUrl(formUrl);
configure.setResourceOriginUrlDomain(resourceOriginUrlDomain);
configure.setResourceReplaceUrlDomain(resourceReplaceUrlDomain);
configure.setUrlMapping(urlMapping);
AgentService.setLogLevel(logLevel);
configure.setDefaultMediaOptions(defaultMediaOptions);
configure.setMaxUploadFileSize(maxUploadFileSize);

if (whiteboardInfo && whiteboardInfo.hostName && whiteboardInfo.whiteboardPath) {
	configure.setWhiteBoardInfo(whiteboardInfo);
}
configure.setPreferenceSettings({ ...configure.preferenceSettings});

if (AgentService.rootContainer) {
	const root = createRoot(AgentService.rootContainer); // createRoot(container!) if you use TypeScript
	root.render(
		<Provider store={store}>
			<AppProviders>
				<ConfigProvider locale={zhCN}>
					<App />
				</ConfigProvider>
			</AppProviders>
		</Provider>
	);
}
